﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace JTG.ServiceInterface.Printer
{
    public class Printer407
    {
        public Printer407()
        {
            //判断当前运行环境，如果是64位则使用64位dll，否则使用32位dll
            if (IntPtr.Size == 8)
            {
                //return 64;
                File.Copy(".\\PrinterUtility\\PrinterUtility64.dll", "PrinterUtility.dll",
                    true); //三个参数分别是源文件路径，存储路径，若存储路径有相同文件是否替换
            }
            else
            {
                //return 32;
                File.Copy(".\\PrinterUtility\\PrinterUtility.dll", "PrinterUtility.dll", true); //三个参数分别是源文件路径，存储路径，若存储路径有相同文件是否替换
            }
        }

        [DllImport("PrinterUtility.dll")]
        static extern int IsPrinterOnline(string deviceId);
        public int IsOnline(string deviceId)
        {
            return IsPrinterOnline(deviceId);
        }

    }
}
